﻿using GDGeek;
using System;
using UnityEngine;

namespace MrPP.SerriedCabinet
{
    public class SerriedCabinetCtrl : MonoBehaviour
    {
        [SerializeField]
        BoxProcess _box;
        [SerializeField]
        SearchProcess _search;
        [SerializeField]
        WindowProcess _process;
        internal void init()
        {

        }
        [SerializeField]
        SetAsgardPose _anchor = null;
        private AsgardPoseData pose_ = null;
        internal void post(Tuple<string, object> kv)
        {
            Debug.Log("message:"+kv.Item1);
            if (kv.Item1 == "anchor")
            {
                AsgardPoseData data = (AsgardPoseData)kv.Item2;
                if (pose_ == null)
                {
                    _anchor._pose = data.aPose;
                    _process.doVuforia(_anchor.transform);
                }
                pose_ = data;
            }
            else if (kv.Item1 == "touch") {
                if (pose_ != null)
                {
                    _anchor._pose = pose_.aPose;
                }
            }
            else if (kv.Item1 == "qrcode")
            {
                _process.doQrcode((string)kv.Item2);
            }
            else if (kv.Item1 == "close")
            {
                _process.doClose();
            }
            else if (kv.Item1 == "ventilate")
            {
                _process.onVentilate();
            }
            else if (kv.Item1 == "stop")
            {
                _process.onStop();
            }
            else if (kv.Item1 == "open")
            {
                _process.onOpen();
            }
            else if (kv.Item1 == "open_id")
            {
                _process.onOpen((int)kv.Item2);
            }
            else if (kv.Item1 == "select")
            {
                _process.onSelect((int)kv.Item2);
            }
            else
            {
                _search.post(kv.Item1, kv.Item2);
                _box.post(kv.Item1, kv.Item2);
            }
           




        }
    }
}